package com.sy.server.mapper;

import com.sy.server.vo.CostWithStr;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class CostWithStrSqlProvider {
    public String updateByDate(CostWithStr record){
        BEGIN();
        UPDATE("cost");
        if(record.getStr().equals("eat")){
            SET("eat = #{eat,jdbcType=DOUBLE}");
            SET("eat_detail=#{eatDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("house")){
            SET("house = #{house,jdbcType=DOUBLE}");
            SET("house_detail = #{houseDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("communication")){
            SET("communication = #{communication,jdbcType=DOUBLE}");
            SET("communication_detail = #{communicationDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("traffic")){
            SET("traffic = #{traffic,jdbcType=DOUBLE}");
            SET("traffic_detail = #{trafficDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("daily")){
            SET("daily = #{daily,jdbcType=DOUBLE}");
            SET("daily_detail = #{dailyDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("education")){
            SET("education = #{education,jdbcType=DOUBLE}");
            SET("education_detail = #{educationDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("clothes")){
            SET("clothes = #{clothes,jdbcType=DOUBLE}");
            SET("clothes_detail = #{clothesDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("snacks")){
            SET("snacks = #{snacks,jdbcType=DOUBLE}");
            SET("snacks_detail = #{snacksDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("fruits")){
            SET("fruits = #{fruits,jdbcType=DOUBLE}");
            SET("fruits_detail = #{fruitsDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("medical")){
            SET("medical = #{medical,jdbcType=DOUBLE}");
            SET("medical_detail = #{medicalDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("others")){
            SET("others = #{others,jdbcType=DOUBLE}");
            SET("others_detail = #{othersDetail,jdbcType=VARCHAR}");
        }
        if(record.getStr().equals("todayEvent")){
            SET("today_event = #{todayEvent,jdbcType=VARCHAR}");
        }
        WHERE("day = #{day,jdbcType=VARCHAR} and user_id=#{userId,jdbcType=INTEGER}");
        return SQL();
    }

}
